package hn.cch.spring.aop.aspect;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;

import java.util.Arrays;

public class MethodInterceptorImpl implements MethodInterceptor {

    private static final Logger logger = LoggerFactory.getLogger(MethodInterceptorImpl.class);

    @Nullable
    @Override
    public Object invoke(@NonNull MethodInvocation methodInvocation) throws Throwable {
        logger.debug("before:{}", Arrays.toString(methodInvocation.getArguments()));
        Object proceed = methodInvocation.proceed();
        logger.debug("after:{}", proceed);
        return proceed;
    }
}
